import { Logger } from "./Logger";
import DateUtil from "./DateUtil";
const md5 = require('./md5');
// const md5 = require('md5');


export class Md5Helper {

    private static Private_Key: string = "jhao_yuxiaxie"

    public static init(key: string = "jhao_yuxiaxie") {
        this.Private_Key = key;
    }

    public static getMd5Default(str: string) {
        let md5Key: string = md5(str);
        // Logger.log("getMd5Default=====", md5Key);
        return md5Key;
    }


    public static getMd5_encrypt(str: string) {
        let md5Key: string = md5("{" + str + this.Private_Key + "}");
        return md5Key;
    }

    public static createToken(userName: string) {
        let token: string = this.getMd5_encrypt(userName + DateUtil.now())
        return token;
    }

}
